import axios from '@/axios'

// 获取商品列表
export const getGoodsListAPI = (page, params) => {
  return axios.get(`/admin/goods/${page}`, { params })
}

// 增加商品
export const addGoodsAPI = (data) => {
  return axios.post('/admin/goods', data)
}

// 批量上架下架商品
export const updateGoodsStatusAPI = (ids, status) => {
  return axios.post(`/admin/goods/changestatus`, {
    ids,
    status,
  })
}
// 修改商品
export const updateGoodsAPI = (id, data) => {
  return axios.post(`/admin/goods/${id}`, data)
}

// 批量删除商品
export const deleteGoodsAPI = (ids) => {
  return axios.post(`/admin/goods/delete_all`, {
    ids,
  })
}
export const restoreGoodsAPI = (ids) => {
  return axios.post(`/admin/goods/restore`, {
    ids,
  })
}
export const destroyGoodsAPI = (ids) => {
  return axios.post(`/admin/goods/destroy`, {
    ids,
  })
}

export const readGoodsAPI = (id) => {
  return axios.get(`/admin/goods/read/${id}`)
}

export const setGoodsBanner = (id, data) => {
  return axios.post(`/admin/goods/banners/${id}`, data)
}

export const updateGoodsSkusAPI = (id, data) => {
  return axios.post(`/admin/goods/updateskus/${id}`, data)
}

export const createGoodsSkusCardAPI = (data) => {
  return axios.post('/admin/goods_skus_card', data)
}
export const updateGoodsSkusCardAPI = (id, data) => {
  return axios.post(`/admin/goods_skus_card/${id}`, data)
}
export const deleteGoodsSkusCardAPI = (id) => {
  return axios.post(`/admin/goods_skus_card/${id}/delete`)
}
export const sortGoodsSkusCardAPI = (data) => {
  return axios.post(`/admin/goods_skus_card/sort`, data)
}
export const createGoodsSkusCardValueAPI = (data) => {
  return axios.post('/admin/goods_skus_card_value', data)
}
export const updateGoodsSkusCardValueAPI = (id, data) => {
  return axios.post(`/admin/goods_skus_card_value/${id}`, data)
}
export const deleteGoodsSkusCardValueAPI = (id) => {
  return axios.post(`/admin/goods_skus_card_value/${id}/delete`)
}
export const chooseAndSetGoodsSkusCardAPI = (id, data) => {
  return axios.post(`/admin/goods_skus_card/${id}/set`, data)
}
